﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ATEC.ATDataCoreNET;
using ATEC.GeometryNET;
using DoModelExample;
using SSDPNET;
namespace DoDrawExample
{
    public class DrawingProject
    {
        /// <summary>
        /// 绘制轮廓
        /// </summary>
        /// <param name="project"></param>
        public static void DrawProfile(ATProject project)
        {
            string sceneName = "侧面";
            ATScene scene = DrawingFile.CreateScene(sceneName, project, 10, ATScenesType.Drawing);
            if(scene==null)
            {
                return;
            }
    
            CurveSet curveSet_Profile = CreateComponentExample.componentModel.Curve;
            
            for (int i = 0; i < curveSet_Profile.Count; i++)
            {
                CurveSet curve = curveSet_Profile.GetAt(i).GetChildCurveSet().Clone();
                ATEC.ATDataCoreNET.ATObjects.ATObject obj = ATEC.ATDataCoreNET.ATObjects.GeometryToATObject.ToObject(scene.GetATScene(), curve, null);
                ObjectPropertiesSetter setter = new ObjectPropertiesSetter();
                setter.SetColor((uint)3);
                setter.Apply(obj);
                obj.AddToScene();
            }

           
            scene.GetATProject().ProcessChanges(ATSaveReason.ApplicationInitiated);
    
            XPoint3d currentCenterPt= XPoint3d.FromXYZ(0,0, 0);
            XPoint3d destPt = XPoint3d.FromXYZ(2100*100, 1500*100, 0);//图框中的点
            XPoint3d MoveVec =SSDPNET.Geom.XVector3dExtension.FromStartEnd(currentCenterPt, destPt);
            StatusInt status = DrawingFile.AttachDbScene(project, scene, MoveVec, 1/ 10, XMatrix3d.Identity, true);

            if (status != StatusInt.Success)
            {
                ATOutputFuncs.OutputMessageCenter(ATOutputFuncs.OutputMessagePriority.Error, "参照scene失败",
                   "参照scene失败", ATOutputFuncs.OutputMessageAlert.Balloon);
            }

        }
        /// <summary>
        /// 刷新左树栏
        /// </summary>
        /// <param name="node"></param>

        public static void RefreshTreeNode(TreeNode node)
        {
            if(node==null)
            {
                return;
            }
            string nodeName = "构件" + "(" + CreateComponentExample.componentModel.component.startStation.ToString() + "~"
                + CreateComponentExample.componentModel.component.endStation.ToString() + ")" + "图纸";
            TreeNode newNode = new TreeNode(nodeName);
            node.Nodes.Add(newNode);
        }


    }
}
